#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    //Instanciar el Server
    this->dispServer = new Server();
    //Definir al server log, con el txtEdit de la ventana
    this->dispServer->log = this->ui->txtLog;
    this->dispServer->test = this->ui->txtTest;
    //Apuntadores de los objetos graficos hacia el server
    //ProductoA
    this->dispServer->spinA = this->ui->spinBox;
    this->dispServer->sliderA = this->ui->horizontalSlider;
    //ProductoB
    this->dispServer->spinB = this->ui->spinBox_2;
    this->dispServer->sliderB = this->ui->horizontalSlider_2;
    //ProductoC
    this->dispServer->spinC = this->ui->spinBox_3;
    this->dispServer->sliderC = this->ui->horizontalSlider_3;
}

Dialog::~Dialog()
{
    delete ui;
    //Liberar Servidor
    delete this->dispServer;
}

/*void Dialog::AlCrearProductos(int number)
{
    ui->horizontalSlider->setValue(number);
    ui->spinBox->setValue(number);
}*/
void Dialog::on_btnIniciar_clicked()
{
    this->dispServer->start(7777);
}

void Dialog::on_btnParar_clicked()
{
    this->dispServer->stop();
    this->dispServer->~Server();
    //ProductoA->Stop = true;
}

void Dialog::on_btnSalir_clicked()
{
    this->dispServer->stop();
    this->close();
}
